package cn.cyxcoder.demo.controller;

import cn.cyxcoder.demo.producer.MessageProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private MessageProducer messageProducer;

    @GetMapping("/normal")
    public String sendNormalMessage() {
        messageProducer.sendNormalMessage("这是一条普通消息");
        return "普通消息发送成功";
    }

    @GetMapping("/delay")
    public String sendDelayMessage() {
        messageProducer.sendDelayMessage("这是一条延时消息", 3);
        return "延时消息发送成功";
    }

    @GetMapping("/order")
    public String sendOrderMessage() {
        messageProducer.sendOrderMessage("这是一条顺序消息", "ORDER-001");
        return "顺序消息发送成功";
    }

    @GetMapping("/transaction")
    public String sendTransactionMessage() {
        messageProducer.sendTransactionMessage("这是一条事务消息");
        return "事务消息发送成功";
    }
} 